﻿#ifndef VIDEOFRAMEFILTER_H
#define VIDEOFRAMEFILTER_H
#include "FrameFilter.h"

extern "C"
{
#include <libavutil/pixfmt.h>
}

struct SwsContext;

class VideoFrameFilter : public IFrameFilter
{
public:
    VideoFrameFilter();

    int init(int  inWidth,int inHeight, AVPixelFormat inFmt, int outWidth, int outHeight, AVPixelFormat outFmt);

    void uninit();

    virtual ~VideoFrameFilter();

    AVFrame *filter(AVFrame *frame) override;

private:
    SwsContext* m_sws_ctx = nullptr;
    int m_srcW = 0;
    int m_srcH = 0;
    AVPixelFormat m_srcFmt = AV_PIX_FMT_YUV420P;
    int m_dstW, m_dstH;
    AVPixelFormat m_dstFmt;
};

#endif // VIDEOFRAMEFILTER_H
